package com.tongchengsoft.interceptors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
public class LoginInterceptors  extends HandlerInterceptorAdapter {

	/**
	 * 日志对象
	 */
	
//	private static final String[] filterURL = {"/advisoryUser/findAll", "/advisoryUser/edit", "/advisoryUser/count", "/list_advisory_user.jsp", "/add_brands.jsp", "/list_brands.jsp", "/update_brands.jsp", "/list_order.jsp", "/update_order.jsp",
//	"/add_phone_support_city.jsp", "/update_phone_support_city.jsp", "/list_support_city.jsp", "/add_phone_support_color.jsp", "/update_phone_support_color.jsp", 
//	"/list_phone_support_color.jsp", "/add_phone_type.jsp", "/update_phone_type.jsp", "/list_phone_type.jsp", "/add_repair_position.jsp", "/update_repair_position.jsp", 
//	"/list_repair_position.jsp", "/add_shipping_address.jsp", "/list_shipping_address.jsp", "/update_shipping_address.jsp", "/index.jsp", 
//	 "/backOrder/findAll", "/backOrder/input", "/backOrder/edit", "/backOrder/delete", "/brands/findAll", "/brands/add", "/brands/input",
//	"/brands/edit", "/brands/delete", "/phoneSupportCity/addJump", "/phoneSupportCity/findAll", "/phoneSupportCity/add", "/phoneSupportCity/input", "/phoneSupportCity/edit",
//	"/phoneSupportCity/delete", "/phoneSupportCity/loadCity", "/phoneSupportColor/addJump", "/phoneSupportColor/add", "/phoneSupportColor/findAll", "/phoneSupportColor/input",
//	"/phoneSupportColor/edit", "/phoneType/findAll", "/phoneType/input", "/phoneType/edit", "/phoneType/add", "/phoneType/addJump", "/phoneType/delete", "/repairPosition/findAll",
//	"/repairPosition/loadPhoneType", "/repairPosition/addJump", "/repairPosition/input", "/repairPosition/add", "/repairPosition/edit", "/repairPosition/delete",
//	"/shippingAddress/findAll","/shippingAddress/input", "/shippingAddress/edit", "/shippingAddress/add", "/adminIndex" };
	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//		try {
//			//获取请求路径 
//	        String url = request.getRequestURL().toString();
//	        //读取Session中 登录的 用户ID
//	        Object admin = request.getSession().getAttribute("ADMIN");
//	        //判断 当前请求路径 是否在拦截范围内
//	        for (String s : filterURL) {
//	            if (url.contains(s)) {
//	            	//当前请求路径 在拦截范围内时 判断 session 用户ID是否为空
//	                if(null == admin){
//	                    response.sendRedirect(request.getContextPath()+"/adminAccount/jumpLogin");
//	                    return false;
//	                }
//	            }
//	        }
//		} catch (Exception e) {
//			throw new Exception(e.getMessage());
//		}
		return true;
	}
}
